package com.blockmeta.bbs.immodule.widget.msgview;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.blockmeta.bbs.baselibrary.utils.LoadPicUtil;
import com.blockmeta.bbs.businesslibrary.util.AccountHelper;
import com.blockmeta.bbs.immodule.R;
import com.blockmeta.bbs.immodule.bean.IMCommonLib;
import com.blockmeta.bbs.immodule.bean.databean.F10ContentBean;
import com.blockmeta.bbs.immodule.dao.ChatMessage;
import com.chad.library.adapter.base.BaseViewHolder;

public class F10MsgView<T extends ChatMessage> extends MsgView<T>{

    public F10MsgView(Context context) {
        super(context);
    }

    @Override
    public int getLayoutId() {
        return R.layout.im_chat_f10;
    }

    @Override
    public void convert(BaseViewHolder helper, T item, T lastItem) {
        super.convert(helper, item, lastItem);
        super.bindCommonControl(helper, item, lastItem);

        F10ContentBean contentBean = getContentBean(item, F10ContentBean.class);
        String deepLink = String.format("blockmeta://market/coinf10?symbol=%s&coin_key=%s", contentBean.getSymbol(), contentBean.getCoin_key());
        //发送消息！
        String title = (contentBean.getCn_name() + "/" + contentBean.getSymbol()).toUpperCase();
        if (item.getType() == ChatMessage.TYPE_SEND) {
            ImageView icon = helper.getView(R.id.right_img_icon);
            LoadPicUtil.loadWithPicasso(icon, contentBean.getLogo());
            helper.setText(R.id.right_coin_name, title);
            helper.setText(R.id.right_coin_desc, contentBean.getDescription());
            View contentLayout = helper.getView(R.id.chat_item_layout_content);
            contentLayout.setTag(deepLink);
            helper.addOnClickListener(R.id.chat_item_layout_content);
        } else {
            //接收消息
            ImageView icon = helper.getView(R.id.left_img_icon);
            LoadPicUtil.loadWithPicasso(icon, contentBean.getLogo());
            helper.setText(R.id.left_coin_name, title);
            helper.setText(R.id.left_coin_desc, contentBean.getDescription());
            View contentLayout = helper.getView(R.id.left_chat_item_layout_content);
            contentLayout.setTag(deepLink);
            helper.addOnClickListener(R.id.left_chat_item_layout_content);
        }

    }

}
